<?php
class Data_Node {

    private $stream_url = NULL;
    private $title = NULL;
    private $description = NULL;
    private $date = NULL;
    private $link = NULL;

    public function setStreamUrl( $url ) {
        $this->stream_url = $url;

        return $this;
    }

    public function getStreamUrl() {
        return $this->stream_url;
    }

    /**
     * Получить уникальный ID данной записи
     *
     * @todo Реализовать
     *
     * @return String
     */
    public function getUID() {
        return md5($this->getTitle());
    }

    public function setDescription( DOMNode $node  ) {
        $description = utf8_decode($node->nodeValue);
        if ( trim($description) == trim( $this->getTitle() ) ) {
            $description = '';
        }

        $this->description = $description;

        return $this;
    }

    public function setLink( DOMNode $node ) {
        $link = NULL;
        if ( !($node instanceof DOMText) ) {
            $link = $node->getAttribute("href");
        } 

        $this->link = $link;

        return $this;
    }

    public function setTitle( DOMNode $node ) {
        $this->title = utf8_decode($node->nodeValue);

        return $this;
    }

    public function setDate( DOMNode $node ) {
        $this->date = utf8_decode($node->nodeValue);

        return $this;
    }

    public function getDate() {
        return $this->date;
    }

    public function getLink() {
        return $this->link;
    }

    public function getTitle() {
        return $this->title;
    }

    public function getDescription() {
        return $this->description;
    }
}